<!DOCTYPE html>
<html>
    <head>
        <title>
        </title>
        <link href="/layui/css/layui.css" media="all" rel="stylesheet">
        </link>
    </head>
    <body>
        <script src="/layui/layui.js">
        </script>
        <form class="layui-form">
            <table class="layui-table" id="demo" lay-filter="demo">
                <colgroup>
                    <col width="150">
                        <col width="200">
                            <col>
                            </col>
                        </col>
                    </col>
                </colgroup>
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>明细科目</th>
                        <th>直拨饮料酒水</th>
                        <th>领用饮料酒水</th>
                        <th>进货合计</th>
                        <th>耗用原材料</th>
                        <th>月期末盘点金额</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($month as $item)
                    <tr>
                        <td>
                            {{$loop->iteration}}
                        </td>
                        <td>
                            {{$item}}
                        </td>
                        <td>
                            <input autocomplete="off" lay-data="straight_alcohol_{{$loop->iteration}}" class="layui-input straight_alcohol" lay-verify="number" name="straight_alcohol_{{$loop->iteration}}" placeholder="请输入" required="" type="text" value="0"/>
                        </td>
                        <td>
                            <input autocomplete="off" lay-data="receive_alcohol_{{$loop->iteration}}" class="layui-input receive_alcohol" lay-verify="number" name="receive_alcohol_{{$loop->iteration}}" placeholder="请输入" required="" type="text" value="0"/>
                        </td>
                        <td>
                            <input autocomplete="off" lay-data="purchase_sum_{{$loop->iteration}}" class="layui-input purchase_sum" lay-verify="number" name="purchase_sum_{{$loop->iteration}}" placeholder="请输入" required="" type="text" value="0"/>
                        </td>
                        <td>
                            <input autocomplete="off" lay-data="reduce_material_sum_{{$loop->iteration}}" class="layui-input reduce_material_sum" lay-verify="number" name="reduce_material_sum_{{$loop->iteration}}" placeholder="请输入" required="" type="text" value="0"/>
                        </td>
                        <td>
                            <input autocomplete="off" lay-data="month_of_end_sum_{{$loop->iteration}}" class="layui-input month_of_end_sum" lay-verify="number" name="month_of_end_sum_{{$loop->iteration}}" placeholder="请输入" required="" type="text" value="0"/>
                        </td>
                    </tr>
                    @endforeach
                </tbody>
            </table>
            {{csrf_field()}}
            
<!--             <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn submit" lay-filter="formDemo" lay-submit="">
                        立即提交
                    </button>
                    <button class="layui-btn layui-btn-primary" type="reset">
                        重置
                    </button>
                </div>
            </div> -->
        </form>
        <button class="layui-btn sub">
            立即提交
        </button>
    </body>
</html>
<script>
    //Demo
    layui.use(['form','table'], function () {
        var table = layui.table;
        var form = layui.form;

        //监听提交
        $('.sub').on('click', function() {
            layer.msg('已提交');
            //layer.msg(JSON.stringify(data.field));
            var sum_data = [[],[],[],[],[],[],[],[],[],[],[],[]];
            var month_of_end_sum = []; // 月期末盘点金额
            var purchase_sum = []; //   进货合计
            var receive_alcohol = [];//     领用饮料酒水
            var reduce_material_sum = []; //    耗用原材料
            var straight_alcohol = []; //    直拨饮料酒水
            $('.straight_alcohol').each(function () {
                var values = $(this).val();
                straight_alcohol.push(values);
            });
            $('.reduce_material_sum').each(function () {
                var values = $(this).val();
                reduce_material_sum.push(values);
            });
            $('.receive_alcohol').each(function () {
                var values = $(this).val();
                receive_alcohol.push(values);
            });
            $('.purchase_sum').each(function () {
                var values = $(this).val();
                purchase_sum.push(values);
            });
            $('.month_of_end_sum').each(function () {
                var values = $(this).val();
                month_of_end_sum.push(values);
            });
            for (var i = 0; i <= 11; i++) {
                sum_data[i].push(straight_alcohol[i]);

                sum_data[i].push(receive_alcohol[i]);
                sum_data[i].push(purchase_sum[i]);
                sum_data[i].push(reduce_material_sum[i]);
                sum_data[i].push(month_of_end_sum[i]);
            }

            table.exportFile(['直拨饮料酒水','领用饮料酒水','进货合计','耗用原材料','月期末盘点金额'], sum_data, '吧台存货明细表.csv'); //默认导出 csv，也可以为：xls
        });
    });
</script>